/**
 * Created by Administrator on 17-6-19.
 */
$(function () {
    var _guideStatus = $('#guideStatus');
    var guideStatus = $(_guideStatus).val();
    $('body')
        .on('click', '#guide', function () {
            guide(true);
        });
    function guide(again) {
        if (again) {
            var lgEle = '';
            lgEle += '<div class="guide-modal-label">';
            lgEle += '  <div class="modal-backdrop fade in"></div>';
            lgEle += '    <div class="guide-modal-content">';
            lgEle += '      <div class="guide-modal-item-one">';
            lgEle += '        <div class="ml10"><p class="fs16 pt10"><span class="c-4e">您所使用的系统为演示性demo，</span><span class="c-orange"></span></p>';
            lgEle += '        <p class="fs16"><span class="c-4e">除账号外，其它创建内容会在第二天清空</span><br/><span class="c-4e">不能给予保留，请知晓。</span><span class="c-orange">3</span><span class="c-4e">步，</span><span class="c-4e">预计</span><span class="c-orange">30</span><span class="c-4e">秒</span></p></div>';
            lgEle += '        <div class="guide-foot"><em>&nbsp;</em><a href="javascript: void(0)" class="btn btn-default guide-close">不需要，已了解</a>';
            lgEle += '        <a href="javascript: void(0)" class="btn btn-default guide-one-go-next guide-go-next">好，我看一下</a></div>';
            lgEle += '      </div>';
            lgEle += '      <div class="guide-modal-item-two">';
            lgEle += '        <div class="guide-jt"><em>&nbsp;</em></div>';
            lgEle += '        <div class="ml10"><h3 class=""><span class="fs18 c-222">引导2—重要系统介绍</span></h3><p class="fs16 pt10"><span class="c-orange fs18">左侧，</span><span class="c-4e">为系统功能菜单</span></p>';
            lgEle += '        <p class="fs16"><span class="c-4e">可以根据自己的工作要求，点击进入相关系统</span><br/><span class="c-4e">注意，菜单为灰色，代表你没有进入权限</span></p></div>';
            lgEle += '        <div class="guide-foot"><em>&nbsp;</em><a href="javascript: void(0)" class="btn btn-default guide-close">结 束</a>';
            lgEle += '        <a href="javascript: void(0)" class="btn btn-default guide-two-go-next guide-go-next">下一步</a></div>';
            lgEle += '      </div>';
            lgEle += '      <div class="guide-modal-item-three">';
            lgEle += '        <div class="guide-jt"><em>&nbsp;</em></div>';
            lgEle += '        <div class="ml10"><h3 class=""><span class="fs18 c-222">引导3—帮助与说明</span></h3><p class="fs16 pt10"><span class="c-4e">如果在操作中出现了问题或疑惑，可点击头部帮助</span></p>';
            lgEle += '        <p class="fs16"><span class="c-4e">进入帮助中心进行自助式解决，</span><br/><span class="c-4e">当然有朋友，同事帮助那也是极好的</span></p></div>';
            lgEle += '        <div class="guide-foot"><em>&nbsp;</em><a href="javascript: void(0)" class="btn btn-default guide-again">重新看一次</a>';
            lgEle += '        <a href="javascript: void(0)" class="btn btn-default guide-four-go-next guide-go-next guide-close">懂了，开始吧！</a></div>';
            lgEle += '      </div>';

            lgEle += '    </div>';
            lgEle += '</div>';

            $('body').append(lgEle);

            var gEle = $('.guide-modal-content'),
                oTop = parseInt($('#side-menu > li').eq(1).offset().top),
                sLeft = parseInt($('.navbar-top-links > li').eq(2).offset().left);

            $('body').on('click', '.guide-one-go-next', function () {
                $(this).parent().parent().hide();
                $('.guide-modal-item-two').show();
                gEle.css({'top': oTop + 124, 'left': '248px'});
            });
            $('body').on('click', '.guide-two-go-next', function () {
                $(this).parent().parent().hide();
                $('.guide-modal-item-three').show();
                gEle.css({'top': '125px', 'left': sLeft - 480})
            });
            $('body').on('click', '.guide-again', function () {
                $(this).parent().parent().hide();
                $('.guide-modal-item-one').show().parent().css({'top': '30%', 'left': '38%'});
            });

            $('.guide-four-go-next, .guide-close').unbind().bind('click', function () {
                gClose();
            });
            var gClose = function () {
                $('.guide-modal-label').hide();
                if(guideStatus==0){
                    //请求修改用户引导状态
                    $.ajax({
                        url: '/admin/manage/updateSysUserGuideStatus',
                        data: {"guideStatus":1},
                        type: 'post',
                        success: function (result) {
                            if(result.success){
                                $(_guideStatus).val("1");
                            }
                        }
                    });
                }
            };

        }
    }
});
